package cn.samir.sudoku.core;

public class Sudokus implements Comparable<Sudokus> {

	// public static int sid = 1000020;
	public int time;// 级别
	public int _id;
	public int sid;//在服务器的id
	public int passed = 0;// 是否通过 0/1
	public String code ;// 通过的人的服务器id.防止多个用户在一个手机上登录，完成的历史记录区分标记，显示不区分
	public int numberHelp;// 不是0的个数
	public int sudokuid;// id 7位数字
	public String content;// 初盘
	public String pauseContent;// 暂时保存
	public String fullContent;// 终盘
	public String description;// 描述
	public int score;// 分数
	public boolean isshow;// 是否在首页显示，展示没用

	public Sudokus(int id, int sudokuid, String content, String description,
			int score) {
		super();
		this.sid = id;
		this.sudokuid = sudokuid;
		this.content = content;
		this.description = description;
		this.score = score;
		int size = content.length();
		for (int i = 0; i < size; i++) {
			if (content.charAt(i) != '0') {
				++numberHelp;
			}
		}
	}

	public Sudokus() {
		super();
		init();
	}

	private void init() {

		isshow = true;
	}

	public Sudokus(String content) {
		super();
		init();
		this.content = content;
		int size = content.length();
		for (int i = 0; i < size; i++) {
			if (content.charAt(i) != '0') {
				numberHelp++;
			}
		}

	}

	public Sudokus(String content, int score) {
		super();
		init();
		this.content = content;
		this.score = score;

	}

	public Sudokus(String content, String description) {
		super();
		init();
		this.content = content;
		this.description = description;

	}

	

	
	@Override
	public int compareTo(Sudokus another) {
		return (this.numberHelp > another.numberHelp ? 1
				: (this.numberHelp == another.numberHelp ? 0 : -1));
		
		
	}

	@Override
	public String toString() {
		return "Sudokus [ id=" + sid + ", passed=" + passed
				+ ", numberHelp=" + numberHelp + ", sudokuid=" + sudokuid
				+ ", content=" + content + ", pauseContent=" + pauseContent
				+ ", fullContent=" + fullContent + ", description="
				+ description + ", score=" + score + ", isshow=" + isshow + "]";
	}

	@Override
	public boolean equals(Object o) {
		String contents = ((Sudokus) o).content;
		return this.content.equals(contents);
	}

	@Override
	public int hashCode() {
		return content.hashCode();
	}

}
